/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.aurelius;

import javax.activation.DataSource;
import javax.annotation.PostConstruct;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 *
 * @author Lukasz
 */
public class HSQLSchemaCreator {

    private String schemaName;
    private JdbcTemplate jdbcTemplate;

    public HSQLSchemaCreator(String schemaName, JdbcTemplate jdbcTemplate) {
        this.schemaName = schemaName;
        this.jdbcTemplate = jdbcTemplate;
    }

    @PostConstruct
    public void postConstruct() throws Exception {
        jdbcTemplate.execute("DROP SCHEMA IF EXISTS " + schemaName + " CASCADE ");
        jdbcTemplate.execute("CREATE SCHEMA " + schemaName + " AUTHORIZATION DBA");
    }
}
